/**
 * 
 */
package com.alstudio.module.xmpp.protocol.xmpp.util.xmlcreator.iq.useroption;

import com.alstudio.module.xmpp.protocol.xmpp.data.ALXmppData;
import com.alstudio.module.xmpp.protocol.xmpp.packact.ALXmppDomainConfig;
import com.alstudio.module.xmpp.protocol.xmpp.packact.IQNameSpace;
import com.alstudio.module.xmpp.protocol.xmpp.util.xmlcreator.AlXmlTag;
import com.alstudio.module.xmpp.protocol.xmpp.util.xmlcreator.iq.BaseIQTemplate;

/**
 * 组装反馈iq
 * @author alonso lee
 *
 */
public class SendFeedBackIQCreator extends BaseIQTemplate {
	
	private ALXmppData data;
	
	/**
	 * 
	 */
	public SendFeedBackIQCreator(ALXmppData data,String domain) {
		// TODO Auto-generated constructor stub
		this.data = data;
		this.domain = domain;
	}

	/* (non-Javadoc)
	 * @see com.alstudio.module.xmpp.protocol.xmpp.util.xmlcreator.iq.BaseIQTemplate#getIQXml()
	 */
	@Override
	public String getIQXml() {
		// TODO Auto-generated method stub

		to = ALXmppDomainConfig.getALXmppDomainConfig().getDomainByNameSpace(
				IQNameSpace.NS_SUGGEST);
		mALIQCreator.setTo(to + domain);
		mALIQCreator.setNs(IQNameSpace.NS_SUGGEST);
		mALIQCreator.setType(IQ_TYPE_SET);
		
		//反饋內容
		AlXmlTag tag = new AlXmlTag("body");
		tag.setText((String)data.getData());
		tagList.add(tag);
		
		// os
		AlXmlTag osTag = new AlXmlTag("os");
		osTag.setText("android");

		// model
		AlXmlTag modelTag = new AlXmlTag("model");
		modelTag.setText(data.getDevInfo().getDeviceModel());

		// sdkversion
		AlXmlTag sdkversionTag = new AlXmlTag("sdkversion");
		sdkversionTag.setText(data.getDevInfo().getSdkVersion());
		
		// 版本号
		AlXmlTag verTag = new AlXmlTag("version");
		verTag.setText(data.getAppVersion());
		// 下载连接
		AlXmlTag downTag = new AlXmlTag("downfrom");
		downTag.setText(data.getDownloadUrl());

		tagList.add(sdkversionTag);
		tagList.add(modelTag);
		tagList.add(osTag);
		tagList.add(verTag);
		tagList.add(downTag);

		String xml = "";
		try {
			xml = mALIQCreator.getXml();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return xml;
	
	}

}
